package com.example.controller.before;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.Banner;
import com.example.service.BannerService;
import com.example.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "Banner小程序管理") //swagger的注释
@CrossOrigin
@RequestMapping("/bannerBefore")
@RestController
public class BannerControllerBefore {

    @Autowired
    private BannerService bannerService;

    @ApiOperation(value = "获取Banner")
    @GetMapping("getBanner")
    public R getBanner() {
        QueryWrapper<Banner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("gmt_create");
        List<Banner> list = bannerService.list(wrapper);
        return R.ok().data("list", list);
    }
}
